<script>
	import {
		HTTP_REQUEST_URL
	} from './config/app';
	export default {
		globalData: {
			spid: 0,
			code: 0,
			openId: '',
			sessionKey: '',
		},
		onLaunch: function(option) {


			uni.onPushMessage((res) => {


			})

			uni.getPushClientId({
				success: (res) => {
					let push_clientid = res.cid
					uni.setStorage({
						key: 'push_clientid',
						data: push_clientid
					});
				},
				fail(err) {
					console.log(err)
				}
			})
	 
			let that = this;
			// #ifdef MP
			if (HTTP_REQUEST_URL == '') {
				console.error(
					"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
				);
				return false;
			}
			if (option.query.hasOwnProperty('scene')) {
				switch (option.scene) {
					//扫描小程序码
					case 1047:
						let val = that.$util.getUrlParams(decodeURIComponent(option.query.scene));
						that.globalData.code = val.pid === undefined ? val : val.pid;
						break;
						//长按图片识别小程序码
					case 1048:
						that.globalData.code = option.query.scene;
						break;
						//手机相册选取小程序码
					case 1049:
						that.globalData.code = option.query.scene;
						break;
						//直接进入小程序
					case 1001:
						that.globalData.spid = option.query.scene;
						break;
				}
			}
			const updateManager = uni.getUpdateManager();

			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
			});

			updateManager.onUpdateReady(function() {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，是否重启应用？',
					success: function(res) {
						if (res.confirm) {
							// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
							updateManager.applyUpdate();
						}
					}
				});
			});

			updateManager.onUpdateFailed(function() {
				return that.Tips({
					title: '新版本下载失败'
				});
			});
			// #endif


		 
			 


			// #ifdef H5


			uni.getSystemInfo({
				success(e) {
					/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
					if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
						window.location.pathname = '/static/html/pc.html';
					}
				}
			});
			// #endif 
			uni.getSystemInfo({
				success: (res) => {

					var system = res.system;
					var uniPlatform = res.uniPlatform;
					var model = res.model;
					var browserName = res.browserName;
					uni.setStorage({
						key: 'system',
						data: system
					});
					uni.setStorage({
						key: 'uniPlatform',
						data: uniPlatform
					});
					uni.setStorage({
						key: 'model',
						data: model
					});
					uni.setStorage({
						key: 'browserName',
						data: browserName
					});
					uni.setStorage({
						key: 'screenHeight',
						data: res.screenHeight
					});
					uni.setStorage({
						key: 'deviceBrand',
						data: res.deviceBrand
					});
					uni.setStorage({
						key: 'brand',
						data: res.brand
					});
					uni.setStorage({
						key: 'appVersion',
						data: res.appVersion
					});
					uni.setStorage({
						key: 'deviceModel',
						data: res.deviceModel
					});

					uni.setStorage({
						key: 'osAndroidAPILevel',
						data: res.osAndroidAPILevel
					});

					uni.setStorage({
						key: 'romName',
						data: res.romName
					});
					uni.setStorage({
						key: 'romVersion',
						data: res.romVersion
					});
					uni.setStorage({
						key: 'platform',
						data: res.platform
					});




				}
			})

		},
		onShow: function() {

			// #ifdef APP
			//清理系统通知栏消息和app角标
			plus.push.clear()
			plus.runtime.setBadgeNumber(0)
			// #endif

		},
		onHide: function() {
			console.log('App Hide')
		},
		mounted() {




		}
	}
</script>

<style lang="scss">
	page {
		// max-width: 750rpx;
		margin: auto;
		background: #fff;
		scrollbar-width: none;
		/* firefox */
		-ms-overflow-style: none;
		/* IE 10+ */
		overflow-x: hidden;
		overflow-y: auto;
		font-size: 28rpx;
	}

	page::-webkit-scrollbar {
		display: none;
		/* Chrome Safari */
	}

	.syspadding {
		padding-top: var(--status-bar-height);
	}

	.uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none;
	}

	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
	}

	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
	@import '@/common/common.css'
</style>